<%= turbo_frame_tag 'issue_detail' do %>
  <%= start_pending_app_tour_tag("issues/detail") %>
  <%
    data = {
      controller: "issue-detail",
      action: "modal:closed@window->issue-detail#goBackHistory",
      "issue-detail-submit-on-title-change-value": local_assigns[:submit_on_title_change],
      "issue-detail-path-for-modal-closed-value": local_assigns[:back_path]
    }
  %>

  <% data.merge!("issue-detail-attach-path-value": attach_issue_file_path(issue)) if issue.persisted? %>

  <%= render Modal::DialogComponent.new(
    hide_close_button: true,
    modal_box: {
      class: "max-w-5xl relative cpy-issue-detail max-h-[95vh] p-0 flex flex-col",
      data: data,
    }) do %>

      <%= render 'issues/issue_detail/header', issue:, form_path: local_assigns[:form_path] %>


      <div class="flex flex-col md:flex-row items-stretch grow h-full">
        <div class="issue-detail p-4 w-full lg:w-[60%] flex flex-col">

          <%= render 'issues/issue_detail/title', issue:, form_path: local_assigns[:form_path] %>

          <%= render partial: "issues/issue_detail/issue_finished_at", locals: { issue: } %>

          <div class="flex-col lg:flex-row flex gap-2">
            <%= render 'issues/issue_detail/labels', issue:, form_path: local_assigns[:form_path] %>
            <%= render 'issues/issue_detail/due_date', issue:, form_path: local_assigns[:form_path] %>
          </div>

          <div class="" data-controller="dropzone" data-action="dropzone:complete->issue-detail#fileUploadCompleted">

            <%= render partial: 'issues/issue_detail/main_form', locals: { issue:, form_path: local_assigns[:form_path] } %>

          </div>
        </div>

        <div class="w-full lg:w-[40%] bg-base-200/40 p-4">
          <%= render partial: 'issues/comments/comments', locals: { issue: } if issue.persisted? %>
        </div>
      </div>
    <% end %>
<% end %>
